package spil;

public class Gameboard {
	public static final int FIELD_NUMBER = 40;
	private int ownableNumber;
	private Field[] fields;
	private Ownable[] ownables;

	public Gameboard() {
		fields = new Field[FIELD_NUMBER];
	}

	public void setFields() {
		fields = new Field[FIELD_NUMBER];
		fields[0] = new Refuge(200, 1);
		fields[1] = new Territory(20, 60, 60, 300, 2);
		fields[2] = new Chance(3);
		fields[3] = new Territory(20, 60, 60, 300, 4);
		fields[4] = new Tax(200, 5);
		fields[5] = new Fleet(200, 6);
		fields[6] = new Territory(40, 100, 100, 500, 7);
		fields[7] = new Chance(8);
		fields[8] = new Territory(40, 100, 100, 500, 9);
		fields[9] = new Territory(45, 120, 120, 600, 10);
		fields[10] = new Jail(11);
		fields[11] = new Territory(50, 140, 140, 700, 12);
		fields[12] = new LaborCamp(150, 13);
		fields[13] = new Territory(50, 140, 140, 700, 14);
		fields[14] = new Territory(50, 140, 140, 700, 15);
		fields[15] = new Fleet(200, 16);
		fields[16] = new Territory(60, 180, 180, 900, 17);
		fields[17] = new Chance(18);
		fields[18] = new Territory(60, 180, 180, 900, 19);
		fields[19] = new Territory(60, 180, 180, 900, 20);
		fields[20] = new Refuge(0, 21);
		fields[21] = new Territory(70, 220, 220, 1100, 22);
		fields[22] = new Chance(23);
		fields[23] = new Territory(70, 220, 220, 1100, 24);
		fields[24] = new Territory(80, 240, 240, 1200, 25);
		fields[25] = new Fleet(200, 26);
		fields[26] = new Territory(80, 260, 260, 1300, 27);
		fields[27] = new Territory(80, 260, 260, 1300, 28);
		fields[28] = new LaborCamp(150, 29);
		fields[29] = new Territory(85, 280, 280, 1400, 30);
		fields[30] = new Jail(31);
		fields[31] = new Territory(95, 300, 300, 1500, 32);
		fields[32] = new Territory(95, 300, 300, 1500, 33);
		fields[33] = new Chance(34);
		fields[34] = new Territory(100, 320, 320, 1600, 35);
		fields[35] = new Fleet(200, 36);
		fields[36] = new Chance(37);
		fields[37] = new Territory(12, 350, 350, 1750, 38);
		fields[38] = new Tax(100, 39);
		fields[39] = new Territory(150, 400, 400, 2000, 40);
	}

	public void setOwnables() {
		int x = 0;
		ownableNumber = 0;
		for(int i = 0; i < FIELD_NUMBER; i++) {
			if(fields[i] instanceof Ownable)
				ownableNumber++;
		}
		ownables = new Ownable[ownableNumber];
		for(int i = 0; i < FIELD_NUMBER; i++) {
			if(fields[i] instanceof Ownable) {
				ownables[x] = (Ownable) fields[i];
				x++;
			}
		}
	}

	public Field getField(int number) {
		return fields[number-1];
	}

	public Ownable[] getOwnables() {
		return ownables;
	}
}
